/**
  ******************************************************************************
  * @file    OP.c
  * @author  测试1组（houtiezhu）
  * @version v0
  * @date    09-07-2019
  *           
  * @verbatim
  **/
/* Includes ------------------------------------------------------------------*/

#include "define.h"
//#include "SD931X.h"
//#include "SD931X_sin.h"


#define USER_DAC
//OPA配置
void UserOPA_Init(void)
{
	#ifdef USER_DAC
	//OPA配置	user dac
	
	//DAC配置
	DAC_InitTypeDef PWR_DACInitStructure;
	
	PWR_DACInitStructure.DACP=0x00;						//VDP=AVDDR只
	PWR_DACInitStructure.DACN=0x04;						//VDN=VSS
	//PWR_DACInitStructure.DACCode=32;					//DAO=VSS+(AVDDR-VSS)*DABIT[7:0]/255=0+(2.4-0)*32/255=0.301V;
	//PWR_DACInitStructure.DACCode=30;
	//PWR_DACInitStructure.DACCode=29;					//DAO=VSS+(AVDDR-VSS)*DABIT[7:0]/255=0+(2.4-0)*29/255=0.273V;
	PWR_DACInitStructure.DACCode=(23*16);					//DAO=VSS+(AVDDR-VSS)*DABIT[7:0]/255=0+(3.0-0)*23/255=0.271V;
	PWR_DACInitStructure.DAC_DAEN=DISABLE;				//暂时不使能DAC输出
	PWR_DACInit(&PWR_DACInitStructure);
	PWR_DAENCmd(ENABLE);								//使能DAC
	
	
	OP_InitTypeDef OP_InitStructure;
	
	OP_InitStructure.OPNS=OPNS_A6;					//OPA负端选择A6
	OP_InitStructure.OPPS=OPPS_DAO;					//OPA正端选择DAO 内部12bit DAC
	OP_InitStructure.OPCSx=OPCSP;				//OPA同相输出
	OPInit(OPA,&OP_InitStructure);
	OPAOUTChannelConfig(OPAOUT_A7,ENABLE);		//OPA输出端与A7连接
    OPACmd(ENABLE); // 使能OPA输出
//	OP_InitStructure.OPNS=SIN_OPNS_A6;					//OPA负端选择A6
//	OP_InitStructure.OPPS=SIN_OPPS_DAO;					//OPA正端选择DA0
//	OP_InitStructure.SIN_OPCSx=SIN_OPCSP;				//OPA同相输出
//	SIN_OPInit(SIN_OPA,&OP_InitStructure);
//SIN_OPAOUTChannelConfig(SIN_OPAOUT_A7,ENABLE);		//OPA输出端与A7连接
//	SIN_OPACmd(ENABLE);									//使能OPA输出
	
	#else
	
	OP_InitTypeDef OP_InitStructure;
	OP_InitStructure.OPNS=SIN_OPNS_A6;					//OPA负端选择A6
	OP_InitStructure.OPPS=SIN_OPPS_A5;					//OPA正端选择DA0 SIN_OPPS_DAO
	OP_InitStructure.SIN_OPCSx=SIN_OPCSP;				//OPA同相输出
	SIN_OPInit(SIN_OPA,&OP_InitStructure);
	SIN_OPAOUTChannelConfig(SIN_OPAOUT_A7,ENABLE);		//OPA输出端与A7连接
	SIN_OPACmd(ENABLE);									//使能OPA输出
	#endif
}

